package com.tianbing.adlottery.controller.user;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.view.AbstractCachingViewResolver;

import com.tianbing.adlottery.helper.SkinUtils;

/**
 * for create mockup purpose,use a dummy spring controller
 * 
 * @author conan
 * 
 */
public class LogoutController implements Controller {
	private String successView;

	private SkinUtils skinUtils;

	AbstractCachingViewResolver viewResolver;

	/**
	 * @return Returns the successView.
	 */
	public String getSuccessView() {
		return successView;
	}

	/**
	 * @param successView
	 *            The successView to set.
	 */
	public void setSuccessView(String successView) {
		this.successView = successView;
	}

	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		skinUtils.userLogout(request, response);
		// viewResolver.clearCache();
		// viewResolver.removeFromCache("home",null);
		return new ModelAndView(this.getSuccessView());
	}

	public void setSkinUtils(SkinUtils skinUtils) {
		this.skinUtils = skinUtils;
	}

	public void setViewResolver(AbstractCachingViewResolver viewResolver) {
		this.viewResolver = viewResolver;
	}
}
